'''md2creole.py: android (sl4a) wrapper for markdown2creole module

© Dmitri dmych Brechalov, 2011
'''
import sys
import andutils
from andfiledialog import filedialog
from markdown2creole import markdown2creole
import os.path

dirname = '/sdcard'
ifname = andutils.getFileName('Select File', 'Markdown file', dirname, '*.txt')
if not ifname:
    sys.exit(1)
dirname = os.path.split(ifname)[0]
ofname = andutils.getFileName('Create File', 'Creole file', dirname, '*.txt', True)
if not ofname:
    sys.exit(1)
andutils.toast('%s -> %s' % (ifname, ofname))
err = markdown2creole(ifname, ofname)
if err is None:
    andutils.toast('All done')
else:
    andutils.error(err)
